<template>
	<view class="page-notification">
		<view>
			<u-search placeholder="请输入查询内容" v-model="params.noticeTitle" height="60rpx" @search="searchData"
				@custom="searchData"></u-search>
		</view>
		<view>
			<u-list v-if="noticeList.length > 0" @scrolltolower="scrolltolower">
				<u-list-item v-for="(item, index) in noticeList" :key="index" class="notice-item">
					<view @click="navTo(item)">
						<view><text style="color: #606266;"></text><text>{{item.noticeTitle}}</text></view>
						<view class="article-meta">
							<span>{{item.remark}}</span> 
							<span style="font-size: 26rpx;color: #999999;padding-left: 10px;">{{item.createTime}}</span>
						</view>
					</view>
				</u-list-item>
			</u-list>
			<u-empty v-else></u-empty>
			<!-- 	触底显示加载状态 -->
			<uni-load-more :status="status"> </uni-load-more>
		</view>

	</view>
</template>
<script>
	import {
		getNoticelist
	} from "@/api/work/notice/notice"

	export default {

		data() {
			return {
				params: {
					pageNum: 0,
					pageSize: 20,
					title: ''
				},
				noticeList: [],
				total: 0,
				status: "more",
			};
		},
		onLoad() {
			this.params.pageNum = 1
			this.getNoticeData();
		},

		methods: {
			getNoticeData() {
				this.status = "loading"
				const app = this
				getNoticelist(app.params).then(res => {
					this.noticeList = this.noticeList.concat(res.rows);
					this.total = res.total
					if (res.code == '200' || res.code == '401')
						this.$modal.msgSuccess(res.code)
				});
				this.status = "more"
			},
			// 查询按钮动作
			searchData() {
				this.params.pageNum = 1
				this.total = 0
				this.noticeList = []
				this.getNoticeData();
			},
			// 滚动分页加载数据
			scrolltolower() {
				console.log("scrolltolower==" + this.params.pageNum + "===" + this.params.pageSize + "===" + this.total)

				if (this.params.pageNum * this.params.pageSize >= this.total) {

					this.status = "noMore"
					this.$modal.msgSuccess('scrolltolower没有更多数据了')
				} else {
					this.$modal.msgSuccess('scroll=getNoticeData')
					this.params.pageNum += 1;
					this.getNoticeData();
				}

			},

			navTo(row) {
				let noticeId = 0;
				if (row != 0) {
					noticeId = row.noticeId
				}
				this.$tab.navigateTo('/pages/notice/notice?noticeId=' + noticeId)
			}
		}

	};
</script>
<style lang="scss">
	.notice-item {
		padding: 15rpx 0;
	}

	page {
		background-color: #ffffff;
	}

	.article-meta {
		padding: 10rpx 10rpx 10rpx;
		color: #999999;
		border-bottom: 0.5px solid #ededed;
	}

	.page-notification {
		padding: 40rpx;
		height: calc(100vh - 88rpx);
		overflow: hidden;

		.u-list {
			height: calc(100vh - 268rpx) !important;
		}
	}
</style>